{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Render your design to Ansys\n",
    "\n",
    "This notebook describes methods to directly interact with the renderer. As a designer, you might prefer this degree of control. Alternatively, you can decide to only interact with the Analysis modules (described in the 4.* tutorial notebooks) which will take care of some of these operations for you. they also provide a level of abstraction for which you will not need to learn the separate renderers, but seemlesly utilize any of them."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Prerequisite\n",
    "You need to have Ansys installed locally (any version) - at the time of this notebook, Ansys is only supported in Windows.\n",
    "\n",
    "## 1. Create the design in Metal\n",
    "#### 1.1 Preload libraries and classes, then open Metal\n",
    "Let's start by importing all the key libraries and classes, and opening Metal"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%load_ext autoreload\n",
    "%autoreload 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import qiskit_metal as metal\n",
    "from qiskit_metal import designs, MetalGUI\n",
    "from qiskit_metal import Dict, Headings"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from qiskit_metal.renderers.renderer_ansys.ansys_renderer import QAnsysRenderer\n",
    "QAnsysRenderer.default_options"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "design = designs.DesignPlanar()\n",
    "gui = MetalGUI(design)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 1.2 Prepare a design consisting of 4 qubits and 4 CPWs\n",
    "First we import the necessary components and change key global variables to the desired size."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from qiskit_metal.qlibrary.qubits.transmon_pocket import TransmonPocket\n",
    "from qiskit_metal.qlibrary.tlines.meandered import RouteMeander"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "design.variables['cpw_width'] = '15 um'\n",
    "design.variables['cpw_gap'] = '9 um'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's create the 4-Qubit-4-CPWs design in one shot. Feel free to break the cell below into subcells if you would like to more closely follow the layout generation."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Enable overwrite, so that we can re-un this cell multiple times without incurring object name collisions\n",
    "design.overwrite_enabled = True\n",
    "\n",
    "# We now define the same custom options for all the transmons.\n",
    "# We only list the options we intend to modify with respect to the default values\n",
    "options = Dict(\n",
    "    pad_width = '425 um', \n",
    "    pocket_height = '650um',\n",
    "    # Adding 3 connection_pads\n",
    "    connection_pads=Dict(\n",
    "        a = dict(loc_W=+1,loc_H=-1, pad_width='200um'),\n",
    "        b = dict(loc_W=-1,loc_H=+1, pad_height='30um'),\n",
    "        c = dict(loc_W=-1,loc_H=-1, pad_height='50um')\n",
    "    )\n",
    ")\n",
    "\n",
    "# Create the 4 transmons\n",
    "q1 = TransmonPocket(design, 'Q1', options = dict(\n",
    "    pos_x='+2.42251mm', pos_y='+0.0mm', **options))\n",
    "q2 = TransmonPocket(design, 'Q2', options = dict(\n",
    "    pos_x='+0.0mm', pos_y='-0.95mm', orientation = '270', **options))\n",
    "q3 = TransmonPocket(design, 'Q3', options = dict(\n",
    "    pos_x='-2.42251mm', pos_y='+0.0mm', orientation = '180', **options))\n",
    "q4 = TransmonPocket(design, 'Q4', options = dict(\n",
    "    pos_x='+0.0mm', pos_y='+0.95mm', orientation = '90', **options))\n",
    "\n",
    "# Now we do the same for the CPWs\n",
    "options = Dict(\n",
    "        lead=Dict(\n",
    "            start_straight='0.2mm',\n",
    "            end_straight='0.2mm'),\n",
    "        trace_gap='9um',\n",
    "        trace_width='15um')\n",
    "\n",
    "# We define a handy method to shorten the number of line of code necessary to define the 4 CPW\n",
    "def connect(component_name: str, component1: str, pin1: str, component2: str, pin2: str,\n",
    "            length: str, asymmetry='0 um', flip=False, fillet='90um'):\n",
    "    \"\"\"Connect two pins with a CPW.\"\"\"\n",
    "    myoptions = Dict(\n",
    "        fillet=fillet,\n",
    "        hfss_wire_bonds = True,\n",
    "        pin_inputs=Dict(\n",
    "            start_pin=Dict(\n",
    "                component=component1,\n",
    "                pin=pin1),\n",
    "            end_pin=Dict(\n",
    "                component=component2,\n",
    "                pin=pin2)),\n",
    "        total_length=length)\n",
    "    myoptions.update(options)\n",
    "    myoptions.meander.asymmetry = asymmetry\n",
    "    myoptions.meander.lead_direction_inverted = 'true' if flip else 'false'\n",
    "    return RouteMeander(design, component_name, myoptions)\n",
    "\n",
    "# Create the 4 CPWs\n",
    "asym = 140\n",
    "cpw1 = connect('cpw1', 'Q1', 'c', 'Q2', 'b', '5.6 mm', f'+{asym}um')\n",
    "cpw2 = connect('cpw2', 'Q3', 'b', 'Q2', 'c', '5.7 mm', f'-{asym}um', flip=True)\n",
    "cpw3 = connect('cpw3', 'Q3', 'c', 'Q4', 'b', '5.6 mm', f'+{asym}um')\n",
    "cpw4 = connect('cpw4', 'Q1', 'b', 'Q4', 'c', '5.7 mm', f'-{asym}um', flip=True)\n",
    "\n",
    "# Render the entire design to the Qiskit Metal GUI\n",
    "gui.rebuild()\n",
    "gui.autoscale()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2. Render into Ansys HFSS\n",
    "The Ansys HFSS renderer was instantiated during the boot of Qiskit Metal. Let's create a short handle to refer to it in the rest of this notebook."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fourq_hfss = design.renderers.hfss"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 2.1 Connect to or create an Ansys project\n",
    "To setup the project **manually**, follow these instructions:\n",
    "1. Launch `ANSYS Electronics Desktop yyyy Rx` (from your Windows Start menu).\n",
    "2. Create a new Ansys project by clicking on the `New` icon at the top left. (or open an existing project)\n",
    "\n",
    "Alternatively, you can **automatically** set up Ansys by executing the following cell. If Ansys is already open, executing this cell will connect this jupyter notebook session to the currently open windo, project, design and setup. you can modify that later."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fourq_hfss.start()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 2.2 Setup an Ansys HFSS design\n",
    "You can either create a new design or select and use an old one.\n",
    "\n",
    "##### Creating a design\n",
    "\n",
    "To create a new design **manually**, go to the Ansys GUI and follow these instructions:\n",
    "1. Select the project from the leftmost menu in the Ansys GUI.\n",
    "2. Go into the menu `Project` and select `Insert HFSS Design`.\n",
    "3. Change the HFSS design to either eigenmode or modal by right-clicking on the HFSSdesign1 that just got created inside your project (left panel) and then selecting: `Solution Type...`.\n",
    "\n",
    "To create a new design **automatically**, execute one of the following two cells. The first will create a design with eigenmode solution type, the second one will create a design with drivenmodal solution type.\n",
    "\n",
    "NOTE: The design will be added to the project that was active when the command `fourq_hfss.start()` was executed.\n",
    "Note: If a design named `HFSSTransmonQubit` already exists in the project, a new design will be created, with the name suffixed with an incremental integer: `HFSSTransmonQubit1`, `HFSSTransmonQubit2`, etc."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "ansys_design = fourq_hfss.new_ansys_design(\"HFSSMetalEigenmode\", 'eigenmode')\n",
    "ansys_design.name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "ansys_design = fourq_hfss.new_ansys_design(\"HFSSMetalDrivenModal\", 'drivenmodal')\n",
    "ansys_design.name"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### Selecting a design previously created\n",
    "\n",
    "If you created a design with the above commands, it will be automatically selected and linked to this jupyter notebook session. Instead, if you want to use a design that had been created beforehand in the project, you can select it by following one of following three approaches:\n",
    "* manually activating the design from the Ansys GUI, **before** you run the `fourq_hfss.start()` command. In the Ansys GUI, you will find the list of designs in the leftmost panel, and you can activate them with a double click.\n",
    "* using method `fourq_hfss.connect_ansys(*with parameters*)`, specifying which design to connect to.\n",
    "* using method `activate_ansys_design('name')`.\n",
    "\n",
    "The next two cells exemplify how to use the last method. We will switch between the two designs that we previously created.\n",
    "\n",
    "NOTE: this method will also create a design with the given name if the design name is not found, to be able to create a new design it will need to be given the solution type, for example: `fourq_hfss.activate_ansys_design(\"newEigen\", 'eigenmode')`. Failure to specify the type will result in an error message asking to specify the the `solution_type` parameter."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fourq_hfss.activate_ansys_design(\"HFSSMetalEigenmode\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fourq_hfss.activate_ansys_design(\"HFSSMetalDrivenModal\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 2.3 Render some component from the Metal design\n",
    "\n",
    "Find below several rendering examples. You can choose to only execute one of them if you are just browsing this notebook.\n",
    "\n",
    "Notice how we explicitly clear the design before re-rendering. Indeed `render_design()` only adds shapes to the Ansys design. Re-rendering the same shapes will cause violations."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fourq_hfss.render_design()  # entire Metal design."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fourq_hfss.clean_active_design()\n",
    "fourq_hfss.render_design(['Q1'], [('Q1', 'b'), ('Q1', 'c')])  # single qubit with 2 endcaps."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fourq_hfss.clean_active_design()\n",
    "fourq_hfss.render_design(['Q1', 'cpw1', 'Q2'], [('Q1', 'b'), ('Q2', 'c')])  # 2 qubits and 2 endcaps, one per qubit."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For Driven-Modal analysis, we can also add terminations. In the example below we render 1 qubit with 1 endcap and 1 port with a 70 Ohm termination."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fourq_hfss.clean_active_design()\n",
    "fourq_hfss.render_design(['Q2'], [('Q2', 'a')], [('Q2', 'b', '70')])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In the previous examples, rendering area dimensions is determined by the size of the selected geometries, with some buffer.\n",
    "\n",
    "For a more accurate control of the chip size, you need to disable the buffering as below. This will use `design._chips['main']['size']` to determine the rendering area dimensions."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "design._chips['main']['size']['size_y'] = '6mm'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fourq_hfss.clean_active_design()\n",
    "fourq_hfss.render_design([], [], box_plus_buffer=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can also modify the chip size directly by updating `design._chips['main']['size']`. Example below.\n",
    "\n",
    "NOTE: we purposfully make the chip size smaller than the size of the geometry. This will cause a warning to show which will need to be fixed by the user intending to conduct a valid analysis."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fourq_hfss.clean_active_design()\n",
    "design._chips['main']['size']['size_x'] = '4mm'\n",
    "fourq_hfss.render_design([], [], box_plus_buffer=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#    Return back to original size, for the remainder of the notebook\n",
    "design._chips['main']['size']['size_x'] = '6mm'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 2.4 Create of select a setup\n",
    "This section is only needed if you plan to execute an analysis. This topic will be covered in the tutorial notebooks 4.x.\n",
    "\n",
    "To **select** a setup for the active design, you can use `activate_ansys_setup()`. If the setup exists, the QRenderer will reference the setup, otherwise, will make a new setup with the name give.  If no name given, the default name of \"Setup\" will be used."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fourq_hfss.activate_ansys_setup('SetupNEW')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Finally** disconnect the Metal renderer from the Ansys session.\n",
    "\n",
    "NOTE: If you do not disconnect explicitly, you might not be able to close the Ansys GUI later."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fourq_hfss.stop()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3. Render into Ansys Q3D\n",
    "The Ansys Q3D renderer was instantiated during the boot of Qiskit Metal. Let's create a short handle to refer to it in the rest of this notebook."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fourq_q3d = design.renderers.q3d"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 3.1 Connect to or create an Ansys project\n",
    "See section 2.1 in this notebook for additional details and options."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fourq_q3d.start()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 3.2 Setup an Ansys Q3D design\n",
    "You can either create a new design or select and use an old one.\n",
    "\n",
    "##### Creating a design\n",
    "\n",
    "To create a new design **manually**, go to the Ansys GUI and follow these instructions:\n",
    "1. Select the project from the leftmost menu in the Ansys GUI.\n",
    "2. Go into the menu `Project` and select `Insert Q3D Extractor Design`.\n",
    "\n",
    "To create a new design **automatically**, execute the following cell.\n",
    "\n",
    "NOTE: If a design named `Q3dMetalDesign` already exists in the project, a new design will be created, with the name suffixed with an incremental integer: `Q3dMetalDesign1`, `Q3dMetalDesign2`, etc."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "ansys_design = fourq_q3d.new_ansys_design(\"Q3dMetalDesign\", 'capacitive')\n",
    "ansys_design.name"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### Selecting a design previously created\n",
    "\n",
    "If you created a design with the above commands, it will be automatically selected and linked to this jupyter notebook session. Instead, if you want to use a design that had been created beforehand in the project, you can select it by following one of following three approaches:\n",
    "* manually activating the design from the Ansys GUI, **before** you run the `fourq_hfss.start()` command. In the Ansys GUI, you will find the list of designs in the leftmost panel, and you can activate them with a double click.\n",
    "* using method `fourq_q3d.connect_ansys(*with parameters*)`, specifying which design to connect to.\n",
    "* using method `fourq_q3d.activate_ansys_design('name')`.\n",
    "\n",
    "The next two cells exemplify how to use the last method. The first of the two cells below will create a new design because the name does not corrispond to any design in the project. The second cell will return to the previously created design.\n",
    "\n",
    "NOTE: this method will also create a design with the given name if the design name is not found, to be able to create a new design it will need to be given the solution type, for example: `fourq_hfss.activate_ansys_design(\"newEigen\", 'eigenmode')`. Failure to specify the type will result in an error message asking to specify the the `solution_type` parameter."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fourq_q3d.activate_ansys_design(\"Q3dMetalDesignNEW\", 'capacitive')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fourq_q3d.activate_ansys_design(\"Q3dMetalDesign\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 3.3 Render some component from the Metal design\n",
    "\n",
    "Find below several rendering examples. You can choose to only execute one of them if you are just browsing this notebook.\n",
    "\n",
    "Notice how we explicitly clear the design before re-rendering. Indeed `render_design()` only adds shapes to the Ansys design. Re-rendering the same shapes will cause violations."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "fourq_q3d.render_design()  # entire Metal design."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fourq_q3d.clean_active_design()\n",
    "fourq_q3d.render_design(['Q1'], [('Q1', 'b'), ('Q1', 'c')])  # single qubit with 2 endcaps."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fourq_q3d.clean_active_design()\n",
    "fourq_q3d.render_design(['Q1', 'cpw1', 'Q2'], [('Q1', 'b'), ('Q2', 'c')])  # 2 qubits and 2 endcaps, one per qubit."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In the previous examples, rendering area dimensions is determined by the size of the selected geometries, with some padding.\n",
    "\n",
    "For a more accurate control of the chip size, you need to disable the buffering as below. This will use `design._chips['main']['size']` to determine the rendering area dimensions."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fourq_q3d.clean_active_design()\n",
    "fourq_q3d.render_design([], [], box_plus_buffer=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can also modify the chip size directly by updating `design._chips['main']['size']`. Example below:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fourq_q3d.clean_active_design()\n",
    "design._chips['main']['size']['size_y'] = '4mm'\n",
    "fourq_q3d.render_design([], [], box_plus_buffer=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#    Return back to original size, for the remainder of the notebook\n",
    "design._chips['main']['size']['size_y'] = '6mm'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 3.4 Create of select a setup\n",
    "This section is only needed if you plan to execute an analysis. This topic will be covered in the tutorial notebooks 4.x.\n",
    "\n",
    "To **select** a setup for the active design, you can use `activate_ansys_setup()`. If the setup exists, the QRenderer will reference the setup, otherwise, will make a new setup with the name give.  If no name given, the default name of \"Setup\" will be used."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fourq_q3d.activate_ansys_setup(\"SetupNEW\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Finally** disconnect the Metal renderer from the Ansys session.\n",
    "\n",
    "NOTE: If you do not disconnect explicitly, you might not be able to close the Ansys GUI later."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "fourq_q3d.stop()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If you want to close the Metal GUI, uncomment the following cell"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# gui.main_window.close()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## References - Miscellaneous pyEPR/Ansys commands\n",
    "The following commands are for reference only to better understand how the backend code works. They're not meant to be run directly in this notebook as part of the tutorial."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "import pyEPR as epr\n",
    "\n",
    "Connect to Ansys directly from notebook:\n",
    "\n",
    "pinfo = epr.ProjectInfo(project_path = None, \n",
    "                        project_name = None,\n",
    "                        design_name  = None)\n",
    "modeler = pinfo.design.modeler\n",
    "\n",
    "Access methods within HfssDesign class in pyEPR:\n",
    "\n",
    "epr.ansys.HfssDesign.create_dm_setup\n",
    "epr.ansys.HfssDesign.create_q3d_setup\n",
    "\n",
    "Get project and design names:\n",
    "\n",
    "pinfo.project_name\n",
    "design._design.GetName()\n",
    "\n",
    "Filter qgeometry table:\n",
    "\n",
    "full_table = design.qgeometry.tables['poly']\n",
    "mask = full_table['subtract'] == False\n",
    "table = full_table[mask]\n",
    "\n",
    "Draw centered rectangles:\n",
    "\n",
    "bigsquare = modeler.draw_rect_center([0, 0, 0], x_size=8, y_size=8, name='bigsquare')\n",
    "topright = modeler.draw_rect_center([2, 2, 0], x_size=2, y_size=2, name='topright')\n",
    "\n",
    "Subtracting shapes:\n",
    "\n",
    "modeler.subtract('bigsquare', ['topright'])\n",
    "\n",
    "Draw centered box:\n",
    "\n",
    "modeler.draw_box_center([0, 0, 0], [1, 2, 3])\n",
    "\n",
    "Draw closed polygon:\n",
    "\n",
    "trianglepts = [[-1, 5, 0], [1, 5, 0], [0, 7, 0]]\n",
    "modeler.draw_polyline(trianglepts, closed=True)\n",
    "\n",
    "Draw polyline:\n",
    "\n",
    "smallpts = [[2.85, 0, 0], [3.15, 0, 0]]\n",
    "modeler.draw_polyline(smallpts, closed=False)\n",
    "\n",
    "Sweep one polyline with another:\n",
    "\n",
    "modeler._sweep_along_path('Polyline8', 'Polyline7')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
